package com.feinno.module.security.service;

import com.feinno.framework.common.exception.BusinessException;
import com.feinno.framework.common.service.EntityService;
import com.feinno.module.security.domain.User;

public interface UserService extends EntityService<User> {

	public static final String HASH_ALGORITHM = "SHA-1";
	public static final int HASH_INTERATIONS = 1024;
	public static final int SALT_SIZE = 8;

	/**
	 * 根据登录名获取用户
	 * 
	 * @param loginid
	 * @return
	 */
	User findUserByLoginid(String loginid);

	/**
	 * 创建用户
	 * 
	 * @param user
	 * @throws BusinessException
	 */
	void createUser(User user) throws BusinessException;

	/**
	 * 修改用户 用户登录名称和密码不能通过该方法修改
	 * 
	 * @param user
	 * @throws BusinessException
	 */
	void updateUser(User user) throws BusinessException;

	/**
	 * 修改密码
	 * 
	 * @param user
	 * @param newPassword
	 * @throws BusinessException
	 */
	void changePassword(User user, String newPassword) throws BusinessException;

	/**
	 * 验证密码
	 * 
	 * @param user
	 * @param plaintPassword
	 * @return
	 * @throws BusinessException
	 */
	boolean validatePassword(User user, String plaintPassword)
			throws BusinessException;

}
